using System.Configuration;

namespace Pixeldyne.Core.Configuration
{
	/// <summary>
	/// Configuration helper class.
	/// </summary>
	public abstract class ConfigHelper
	{
		/// <summary>
		/// Gets the application setting.
		/// </summary>
		/// <param name="key">The key.</param>
		/// <returns></returns>
		public static string GetApplicationSetting(string key)
		{
			try
			{
				return ConfigurationManager.AppSettings[key];
			}
			catch
			{
				return "";
			}
		}

		/// <summary>
		/// Gets the connection string.
		/// </summary>
		/// <param name="key">The key.</param>
		/// <returns></returns>
		public static string GetConnectionString(string key)
		{
			try
			{
				return ConfigurationManager.ConnectionStrings[key].ConnectionString;
			}
			catch
			{
				return "";
			}
		}

		/// <summary>
		/// Gets the connection string.
		/// </summary>
		/// <param name="index">The index.</param>
		/// <returns></returns>
		public static string GetConnectionString(int index)
		{
			try
			{
				return ConfigurationManager.ConnectionStrings[index].ConnectionString;
			}
			catch
			{
				return "";
			}
		}

	}
}